//
//  Today_Today_detailTableViewCell.m
//  Time
//
//  Created by dllo on 16/7/26.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "Today_Today_detailTableViewCell.h"

@interface Today_Today_detailTableViewCell ()
<
WKNavigationDelegate,
WKUIDelegate
>

@end


@implementation Today_Today_detailTableViewCell

-(void)dealloc{
    [_webView release];
    [_html release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.webView = [[WKWebView alloc] init];
        self.webView.UIDelegate = self;
        self.webView.navigationDelegate = self;
//        self.webView.scrollView.scrollEnabled = NO;
        
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.webView.frame = CGRectMake(0, 0, SWIDTH, 2000);
    self.webView.scrollView.contentSize = CGSizeMake(SWIDTH, 0);
}

-(void)setHtml:(NSString *)html{
    if (_html != html) {
        [_html release];
        _html = [html retain];
    }
    if (_html != nil) {
        [self.webView loadHTMLString:_html baseURL:nil];
    }
}

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    [self.delegate changeCellHeight:webView.scrollView.contentSize.height width:webView.scrollView.contentSize.width];
    [self.contentView addSubview:self.webView];
}


//-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
//    NSLog(@"webView内容长度%lf  %lf",webView.scrollView.contentSize.height,webView.scrollView.contentSize.width);
//    
//    
//}
@end
